{include file="public/header"}
<body class="">
	<div class="sectionY">
		<a href="javascript:history.back();">
			<img src="__PUBLIC__/home/images/a2_1.png" alt="" class="a1">
		</a>
		<p class="p1">共享豆兑换</p>
	</div>
	<div class="kong1"></div>
	<div class="ecx_section2">
		<form action="">
			<div class="t1">
				<div class="f1 clearfix">
					<span class="s1">剩余共享豆数量：</span>
					<input type="text" disabled value="{$userinfo.wagesall}">
				</div>
				<div class="f1 clearfix">
					<span class="s1">兑换资产：</span>
					<input type="text" name="salary" placeholder="请输入共享豆的数量">
				</div>
				<div class="f1 clearfix">
					<span class="s1">交易密码：</span>
					<input type="password" name="pwd" placeholder="请输入交易密码">
				</div>
				<div class="sub">
					<input type="button" id="submit" value="确认兑换">
				</div>
				<div >
					<p>&nbsp;&nbsp;&nbsp;&nbsp;请联系客服到线下领取。</p>
				</div>
			</div>
		</form>
	</div>
</body>
<script>
	$(function(){
		$('#submit').click(function(){
			layer.alert('待开放！',{icon:5,shade:0.8,title:"友情提示:"});return false;
			var num = $('input[name=salary]').val();
			var pwd = $('input[name=pwd]').val();
			if(num==''){
				layer.alert('请检查您要兑换的资产数量，资产兑换不能为空！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			if(pwd==''){
				layer.alert('请输入交易密码！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			$.ajax({
				type: 'POST',
				url: "{:url('User/atcChange')}",
				dataType: "html",
				data: "num="+num+"&pwd="+pwd,
				success:function(responsestr){
					var str = isJSON(responsestr);
					if(str==1){
						var obj=JSON.parse(responsestr);
						if(obj.s==10){
							layer.msg('成功！',{shade:0.6,time:1000,end:function(){
									window.location.href=window.location.href;
									return false;
								}});
						}else{
							layer.alert(obj.msg,{shade:0.2});return false;
						}
					}else{
						layer.alert('系统正忙，请稍后再试！',{shade:0.2});
					}
				},
				error:function(){
					layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
				}
			});
		});
	})

	function isJSON(str) {
		if (typeof str == 'string') {
			try{
				var obj=JSON.parse(str);
				if(str.indexOf('{')>-1){
					return 1;
				}else{
					return 0;
				}
			}catch(e){
				return 0;
			}
		}
		return 0;
	}
</script>
</html>
